package com.awesumgames.testgame;

import com.awesumgames.awesum.Drawable;
import com.awesumgames.awesum.Primitives;
import com.awesumgames.awesum.Vector3;
import com.awesumgames.awesum.Vector4;
import com.awesumgames.awesum.AwesumGlobal.Awesum;
import com.bulletphysics.collision.shapes.BoxShape;

public class Block extends Drawable {
	public enum Type {NORMAL, BOOST, SUPERBOOST, REDUCE, BREAK, SLIDE};
	public Type type = Type.NORMAL;
	
	Block(Type t, Vector3 position) {
		super();
		type = t;
		pos = position;
	}
	
	public void load() {
		super.load(TraitFlag.Gl.flag | TraitFlag.Phys.flag);
		
		float colors[];
		switch (type) {
			case BOOST:		colors = new float[]{0f, 0f, 1f}; break;
			case SUPERBOOST:colors = new float[]{.5f, .5f, 1f}; break;
			case REDUCE:	colors = new float[]{.7f, 0f, .7f}; break;
			case BREAK:		colors = new float[]{.4f, .7f, .7f}; break;
			case SLIDE:		colors = new float[]{1f, 1f, 1f}; break;
			case NORMAL:
			default:		colors = new float[]{1f, 0f, 0f};
		}
		Vector3 boxDims = new Vector3(.5f, .5f, .5f);
		Primitives.buildRect(this, boxDims, new Vector4(colors[0], colors[1], colors[2], 1f), BreakoutLayer.COLL_BLOCK, BreakoutLayer.MASK_BLOCK);
		phys.collShape = new BoxShape(boxDims);
		phys.init(2.5f, 1f, BreakoutLayer.COLL_BLOCK, BreakoutLayer.MASK_BLOCK);
		phys.receiveCollisions = false;
		phys.body.setMassProps(0f, new Vector3());
		phys.body.setFriction(.2f);
	}

	public void collide(Drawable other, Vector3 pointThis, Vector3 pointThat, Vector3 normalThat) {
		if (other instanceof Ball)
			Awesum.debug("collision with BALL!: " + normalThat.toString());
	}
}
